﻿<!--#include file="h.asp"--><%
'
'	七色虎建站系统
'	用户名修改页面
'	2011.11.2

Sub main
	checkLogin()'验证登录
	Dim a,userid,rs,body_
	Dim name,nameLen
	Dim userName,userRegTime,timeInterval
	hu.title = "修改用户名"
	body_ = "[div=nav]-"&hu.url("?aid=index","首页")&"-"&hu.url("bbs_user.asp","会员中心")&"-修改用户名[/div]"
	a=getN("a", 0)
	userid=user_array(0)
	userName=user_array(1)
	userRegTime=user_array(5)
	timeInterval = DateDiff("d", userRegTime, time_now)
	If a=0 Then
		If timeInterval<8 Then body_ = body_ & "[div=tip]刚注册7天内修改免费[/div]"
		Dim formarray(2)
		formarray(0) = http_path&"bbs_username.asp?a=1||post||提交||新用户名:<br/>"
		formarray(1) = "input||new$$$$20$$16||<br/>"
		formarray(2) = "hidden||"&bbsSid&"$$"&sid&"||"
		body_ = body_ & hu.getForm(formarray)&"<br/>[div=tip]修改用户名消费50"&bbsMoney&"[/div]"
	Else
		name=getD("new","")
		nameLen=len(name)
		If nameLen>16 Or nameLen<2 Then rupt "错误", "用户名长度必须是2-16位!"
		If IsNumeric(Mid(name,1,1)) Then rupt "错误",  "用户名不能以数字开头！"
		Set rs=hu.conn("select top 1 name from 74hu_user where name='"&name&"' and id<>"&userid)
		If Not rs.eof Then
			body_ = body_ & "用户名"""&name&"""已存在！请选择其他用户名"
		Else
			If timeInterval >7 Then 
				billMoney =-50'账单,计算会员修改资料消费
				billPoint =0
				billExpr =0
				Call setUserAmountBySelf(userid, billMoney&","&billPoint&","&billExpr)
			End If
			hu.conn("update 74hu_user set name='"&name&"' where id="&userid)
			body_ = body_ & "用户名修改成功!"
		End If
		rs.close
		Set rs=Nothing
	End If
	hu.body = comUbb(body_)
End Sub

%>